package com.zhg.api;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.slots.block.BlockException;


@RestController
public class TestSentinelApi {
	
    @GetMapping("test")
	public String name() {
    	 
		String resourceName =

				"testSentinel";

		Entry entry =

				null;

		String retVal;

		try {

			entry =

					SphU.entry(resourceName, EntryType.IN);

			retVal =

					"passed";

		} catch (BlockException e) {

			retVal =

					"blocked";

		} finally

		{

			if (entry != null) {

				entry.exit();

			}

		}

		return retVal;
	}

}
